<?php
	//自动收货一小时扫描数据库一次,超过7天时间+延迟时间自动收货 7*24*60*60
	file_put_contents("dingshi.txt", date("Y-m-d H:i:s") . "执行定时任务！自动收货" . "\r\n", FILE_APPEND); 
	$rs=M('order')->field('order_id,shipping_time,delay_time')->where("order_state='30' and refund_state=0" )->select();
	foreach($rs as $key=>$value){
		$endtime=$value['shipping_time']+604800+$value['delay_time'];
		$now=time();
		if($now>$endtime){
			$close_data['order_state']='40';
    		$close_data['finnshed_time']=time();
    		M('order')->where('order_id='.$value['order_id'])->save($close_data);
		}
	}

?>